import ls from '@/utils/cache'
import RTRequest from './request'
import { BASE_URL, TIME_OUT } from './request/request.config'
export default new RTRequest({
  baseURL: BASE_URL,
  timeout: TIME_OUT,
  interceptors: {
    requestInterceptor: (config) => {
      const token = ls.getCache('token') ?? null
      if (token && config.headers) {
        config.headers.Authorization = `Bearer ${token}`
      }
      return config
    },
    responseInterceptor: (res) => {
      return res
    }
  }
})
